package contaKM2012;

import exceptions.InconsistentValueException;
import interfaces.IContaKmWithDisplay;
import interfaces.IDisplay;

public class ContaKmWithDisplay extends ContaKm implements IContaKmWithDisplay {

	IDisplay disp;

	public ContaKmWithDisplay(IDisplay disp) throws InconsistentValueException {
		super();
		this.disp = disp;
	}

	public void inc() throws InconsistentValueException {
		super.inc();
		disp.update(toDisplayStr(km));

	}

	@Override
	public String getDisplayedVal() {
		return disp.getCurVarToShow();
	}

	protected String toDisplayStr(int v) {
		String vs = "" + v;
		while (vs.length() < 6)
			vs = "0" + vs;
		return vs;
	}

}
